﻿
<template>
    <div>
        <!-- 添加按钮 -->
        <div class="btn-add">
            <a class="btn btn-success btn-lg" data-toggle="tooltip" v-show="listType==0" title="标记为已读" @click="Upds()">
                <i class="iconfont icon-yidu"></i>标记为已读
            </a>
            <a class="btn btn-warning btn-lg tip" data-toggle="tooltip" v-show="listType==1" title="标记为未读" @click="Upds()">
                <i class="iconfont icon-weidu"></i>标记为未读
            </a>
            <button type="button" class="btn btn-danger btn-lg" @click="DelPL()"><i class="iconfont icon-shanchu ft12 mr5"></i>批量删除</button>

        </div>
        <!-- 按条件选择 -->
        <div class="tab-filter-type">
            <div class="oh mt20">
                <h5 class="pull-left tr">消息状态：</h5>
                <ul class="tab-type ft14">
                    <li><span class="active" @click="ChangeType(0)">未读消息</span></li>
                    <li @click="ChangeType(1)"><span>已读消息</span></li>
                </ul>
            </div>
            <div class="oh ">
                <h5 class="pull-left tr">全部类型：</h5>
                <ul class="tab-type ft14">
                    <!--<li><span class="active">全部</span></li>-->

                    <li @click="SelectRWType('')"><span class="active">全部消息</span></li>
                    <li v-for="el in XXZXType" @click="SelectRWType(el.MsgType)"><span>{{el.MsgType}}</span></li>
                </ul>
            </div>
        </div>
        <!-- 表格 -->
        <div class="default-tab ft14 padding20 hover-btn">

            <base-table :pzoption="tableop" @selection-change="handleSelectionChange">
            </base-table>

        </div>
        <div>
            <el-pagination background @current-change="handleCurrentChange" :page-size="pagesize" :current-page="nowpage" layout="prev, pager, next" :total="datatotal" style="text-align:center;margin-top:8px"></el-pagination>
        </div>

    </div>
</template>

<script>
    module.exports = {
        props: ['pdata'],
        components: {
            'base-table': httpVueLoader('/ViewV5/Base/Vue/Table.vue')
        },
        data: function () {
            return {
                rztype: "登录日志",
                VIEWS: [],
                SelDSourceItem: {},
                XXZXType: [],
                curRWType: "",
                listType: "0",
                datatotal: 0,
                pagesize: 200,
                nowpage: 1,
                tableop: {
                    title: "信息中心",
                    issel: true,
                    iscz: false,
                    dataset: [],
                    multipleSelection: [],
                    czltabledata: [
                    ],
                    collist: [
                        { colid: "MsgType", colname: "消息类别", isshow: true, istip: true, width:110 },
                        { colid: "MsgContent", colname: "内容", isshow: true, istip: true },
                        { colid: "CRDate", colname: "时间", isshow: true, istip: true, width: 150 },

                    ]
                }
            }
        },
        methods: {
            sel: function (rztype) {
                this.rztype = rztype;
                this.getData();

            },
            handleSelectionChange(val) {
                this.tableop.multipleSelection = val;
            },
            SelectRWType: function (type) {
                this.curRWType = type;
                this.getData();
            },
            ChangeType: function (type) {
                this.listType = type;
                this.getData();
            },
            GetXXZXType: function () {
                var pro = this;
                $.getJSON('/api/Auth/ExeAction?Action=GETUSERCENTERTYPE', {}, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        pro.XXZXType = resultData.Result;
                    }
                })
            },
            getData: function () {
                var pro = this;
                $.getJSON('/api/Auth/ExeAction?Action=GETXXZXISTPAGE', { P1: pro.listType, p: pro.nowpage, Content: "", pagecount: pro.pagesize, msgType: pro.curRWType }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        pro.tableop.dataset = resultData.Result;
                        pro.datatotal = resultData.Result1;
                    }

                })
            },
            DelPL: function () {
                var pro = this;
                var ids = [];
                for (var i = 0; i < pro.tableop.multipleSelection.length; i++) {
                    ids.push(pro.tableop.multipleSelection[i].ID);
                }
                if (ids.length == 0) {
                    this.$notify.error({
                        title: '错误',
                        message: '至少需要选择一条数据才能操作'
                    });
                    return;
                }
                ComFunJS.winconfirm("确认要删除日志吗？", function () {
                    $.getJSON("/api/Auth/ExeAction?Action=DELXXZX", { P1: ids.join() }, function (r) {
                        if (r.ErrorMsg == "") {
                            pro.getData();
                            ComFunJS.winsuccess("操作成功");
                        }
                    })
                }, function () { })
            },
            Upds: function (lb) {
                var pro = this;
                var ids = [];
                for (var i = 0; i < pro.tableop.multipleSelection.length; i++) {
                    ids.push(pro.tableop.multipleSelection[i].ID);
                }
                if (ids.length == 0) {
                    this.$notify.error({
                        title: '错误',
                        message: '至少需要选择一条数据才能操作'
                    });
                    return;
                }
                var status = 1;
                if (pro.listType == 1) { status = 0; }
                $.getJSON("/api/Auth/ExeAction?Action=UPDTEREADSTATES", { P1: ids.join(), s: status }, function (jsonresult) {
                    if ($.trim(jsonresult.ErrorMsg) == "") {
                        ComFunJS.winsuccess("设置成功");
                        pro.getData();
                    }
                })
            },
            handleCurrentChange: function (val) {
                var chi = this;
                chi.nowpage = val;
                chi.getData();
            },
            InitWigetData: function () {
                var pro = this;
                pro.GetXXZXType();
                pro.getData();
            },
        },
        mounted: function () {
            var pro = this;
            pro.$nextTick(function () {
                pro.InitWigetData();
            })

        },
        watch: {

        }
    };
</script>